package org.geektimes.interceptor.jdkproxy;

import java.util.concurrent.Future;
import org.eclipse.microprofile.faulttolerance.Asynchronous;
import org.eclipse.microprofile.faulttolerance.Bulkhead;
import org.eclipse.microprofile.faulttolerance.Fallback;
import org.eclipse.microprofile.faulttolerance.Retry;
import org.eclipse.microprofile.faulttolerance.Timeout;

/**
 * jdk proxy.
 * <br> @author leo
 * <br> @date 2021/7/27
 * <br> @since 1.0.0
 */
@Bulkhead(value = 1)
public interface EchoJdkProxy {

    /**
     * judge is thread pool.
     */
    void bulkhead();

    @Timeout(1)
    void echo(String message);

    @Asynchronous
    Future<Void> echo(Object message);

    @Retry(maxRetries = 3,
            delay = 0, maxDuration = 0, jitter = 0,
            retryOn = UnsupportedOperationException.class)
    @Fallback(fallbackMethod = "fallback")
    String echo(Long value);

    String fallback(Long value);
}
